package com.infonam.data.source.model;

import java.util.Date;
import java.util.LinkedList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
@Entity
@Table(name="inventory", catalog="sakila")
public class Inventory {
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="inventory_id",nullable=false,unique=true)
	private int inventory_id;
	@ManyToOne
	@JoinColumn(name="film_id", nullable=false)
	private Film film_id;
	@ManyToOne()
	@JoinColumn(name="store_id", nullable=false)
	private Store store_id;
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="last_update", nullable=false,columnDefinition="TIMESTAMP default CURRENT_TIMESTAMP on update TIMESTAMP")
	private Date last_update;
	@OneToMany(fetch=FetchType.LAZY, mappedBy="inventory")
	@Cascade({CascadeType.ALL})
	private List<FilmText> filmTextList = new LinkedList<FilmText>();
	@OneToMany(fetch=FetchType.LAZY,mappedBy="inventory")
	@Cascade({CascadeType.ALL})
	private List<Rental> rentalList = new LinkedList<Rental>();
	public int getInventory_id() {
		return inventory_id;
	}
	public void setInventory_id(int inventory_id) {
		this.inventory_id = inventory_id;
	}
	public Film getFilm_id() {
		return film_id;
	}
	public void setFilm_id(Film film_id) {
		this.film_id = film_id;
	}
	public Store getStore_id() {
		return store_id;
	}
	public void setStore_id(Store store_id) {
		this.store_id = store_id;
	}
	public Date getLast_update() {
		return last_update;
	}
	public void setLast_update(Date last_update) {
		this.last_update = last_update;
	}
	public List<FilmText> getFilmTextList() {
		return filmTextList;
	}
	public void setFilmTextList(List<FilmText> filmTextList) {
		this.filmTextList = filmTextList;
	}
	public List<Rental> getRentalList() {
		return rentalList;
	}
	public void setRentalList(List<Rental> rentalList) {
		this.rentalList = rentalList;
	}
	

}
